<?php

/**
 *
 * @author Nguyen Thai Binh
 */



function generate_captcha($width = 180, $height=25, $max1 = 10, $max2 = 20) {
  $ci = & get_instance();
  $ci->load->helper('captcha');
  $i = rand(0, $max1);
  $j = rand(0, $max2);
  $vals = array(
      'word' => $i . '+' . $j . '=?',
      'img_path' => './captcha/',
      'img_url' => base_url() . 'captcha/',
      'font_path' => './font/VINERITC.TTF',
      'img_width' => $width,
      'img_height' => $height,
      'expiration' => 100
  );
  $cap = create_captcha($vals);
  set_userdata('captcha_session', $i + $j);
  return $cap;
}